package org.vshe.improve.spring.prospring3.ch5;

import java.util.Locale;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.GenericXmlApplicationContext;

public class MessageEventPublisher implements ApplicationContextAware {
	private static ApplicationContext _context;
	
	public static void main(String args[]) {
		GenericXmlApplicationContext context = new GenericXmlApplicationContext("ch5/event-publisher-test.xml");
		context.registerShutdownHook();
		context.getBean(MessageEventPublisher.class).publish();
	}

	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		_context = applicationContext;
	}
	
	public void publish() {
		_context.publishEvent(new MessageEvent(this, "PUBLISHED"));
	}
	
}
